package share.storage.io.basic;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

import share.storage.io.DownloadType;

public class BasicFileReader implements share.storage.io.FileReader {

	private RandomAccessFile rf = null;

	public BasicFileReader(java.io.File file) throws FileNotFoundException {
		rf = new RandomAccessFile(file, "r");
	}

	public void seek(long pos) throws IOException {
		rf.seek(pos);
	}

	public long tell() throws IOException {
		return rf.getFilePointer();
	}

	public int read(byte[] bytes) throws IOException {
		return rf.read(bytes);
	}

	public int read(byte[] bytes, int off, int len) throws IOException {
		return rf.read(bytes, off, len);
	}

	public void close() {
		try {
			rf.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public DownloadType getDownloadType() {
		return DownloadType.STREAM;
	}

	public String getLocation() {
		return null;
	}

}
